<?php
$p="";
foreach($_GET as $key=>$val) {
    $$key=$val;
}
if(isset($_GET['logout']) ||  $p=="logout")
{
	doLogout();
    
}
  function registerSessions($username,$grp,$userid){
		  $_SESSION['maUserAdmin']= $username;
		  $_SESSION['maUserGrp']= $grp;
		  $_SESSION['maUserid']= $userid;
		 
		  
		 
		  redirectSesson("index.php");
 }
 function validateSession(){
	if(!isset($_SESSION['maUserAdmin']))
	{
		//header("location:login.php");	
		redirectSesson("login.php");
	}else{
	
	}
 }
 function lvalidate(){
if(isset($_SESSION['maUserAdmin'])&& $_SESSION['maUserAdmin']!= NULL )
	{
		//header("location:login.php");	
		redirectSesson("./");
	}
}
function doLogout()
{
	  $_SESSION['maUserAdmin']= NULL;
	  $_SESSION['maUserGrp']= NULL;
	  $_SESSION['maUserid']= NULL;
	  unset($_SESSION['maUserAdmin']);
	  unset( $_SESSION['maUserGrp']);
      unset($_SESSION['maUserid']);
	  session_destroy();
redirectSesson("../");
}
 function redirectSesson($file){
	header("location:".$file);	 
 }
	
?>